/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/
#pragma once

#include <baja/common.hpp>
#include <baja/math.hpp>

namespace journal { namespace view {

// fwd declarations
struct ipage;
struct inotebook_observer;
struct inotebook;
struct iink_surface;
struct iscene_references;
struct iphoto;
struct ipage_view;

static const size_t NO_PAGE = static_cast<size_t>(-1);

enum class app_setting_id
{
    none,
    background_color
};

enum class command_id
{
    none,
    pen_1,
    pen_2,
    pen_3,
    pen_4,
    pen_5,
    color_black,
    color_red,
    color_blue,
    color_green,
    color_yellow,
    color_pink,
    photo_filesystem,
    photo_camera,
    tool_eraser,
    tool_selection,
    tool_pen,
    copy,
    copy_selection,
    paste,
    add_page,
    undo,
    redo,
    delete_photo,
    ok_photo,
    align_photo,
    cancel_photo,
    ok_page,
    ok_selection,
    bring_to_front_photo,
    delete_page,
    zoom_grid,
    zoom_fit_to_width,
    zoom_full_page,
    expand_stack,
    touch_mode_on,
    touch_mode_off,
    paper_0,
    paper_1,
    paper_2,
    paper_3,
    paper_4
};

enum class paper_type : int
{
    none = INT_MAX,
    paper_0 = 0,
    paper_1,
    paper_2,
    paper_3,
    paper_4,
    count
};

enum class default_folder
{
    pictures,
    documents,
    app,
};

enum class layout_id
{
    none = 0,
    
    fitToWidth = 1,
    full = 2,
    grid = 3,

    count = 3,
};

enum class stack_state
{
    none = 0,
    stacked,
    expanded
};

enum class load_level
{
    none = 0,
    thumbnail,
    thumbnailOrNone, // if you have the thumbnail loaded, keep it, otherwise, stay empty
    full,
    thumbnailOrFull
};

enum class notebook_camera_state : int
{
    idle,
    animating
};

struct page_set
{
    page_set(const size_t minPage_, const size_t maxPage_) :
        minPage(minPage_), maxPage(maxPage_), changeNumber(0) {}

    size_t minPage;
    size_t maxPage;
    baja::uint64 changeNumber;

    bool operator!=(const page_set& other) const
    {
        return (minPage != other.minPage) || (maxPage != other.maxPage);
    }

    const std::wstring str() const
    {
        if (minPage == NO_PAGE)
        {
            BAJA_VERIFY(maxPage == NO_PAGE);
            boost::wformat fmt = boost::wformat(L"range: <empty>, change number: %i")  % changeNumber;
            return fmt.str();
        }
        else
        {
            boost::wformat fmt = boost::wformat(L"range: [%i, %i], change number: %i") % minPage % maxPage % changeNumber;
            return fmt.str();
        }
    }

    bool contains(const size_t pageNumber) const
    {
        return (pageNumber >= minPage && pageNumber <= maxPage);
    }
};

struct page_pointer_context
{
    bool handled;
    baja::math::point3d localPoint;
    bool isHit;
};

struct copy_info
{
    bool selection;
    m::point2d origin;
    m::point2d dimensions;
};

}} // namespace journal::view